package com.flynn.rock.system.entity;

import com.flynn.rock.enums.BusinessType;
import com.flynn.rock.enums.OperateType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Getter
@Setter
@Entity
@Table(name = "sys_operate_log")
@EntityListeners(AuditingEntityListener.class)
public class SysOperateLogEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "operate_log_id", nullable = false)
    private Long id;

    @Column(name = "operate_title", length = 64)
    private String operateTitle;

    @Enumerated(EnumType.STRING)
    @Column(name = "operate_type", length = 32)
    private OperateType operateType;

    @Enumerated(EnumType.STRING)
    @Column(name = "business_type", length = 32)
    private BusinessType businessType;

    @Column(name = "operate_user_id")
    private Long operateUserId;

    @Column(name = "operate_user_name")
    private String operateUserName;

    @Column(name = "operate_dept_id")
    private Long operateDeptId;

    @Column(name = "operate_address")
    private String operateAddress;

    @Column(name = "operate_ip", length = 64)
    private String operateIp;

    @Column(name = "request_url", length = 1024)
    private String requestUrl;

    @Column(name = "request_method", length = 32)
    private String requestMethod;

    @Column(name = "request_params", length = 1024)
    private String requestParams;

    @Column(name = "response_params", length = 1024)
    private String responseParams;

    @Column(name = "consume_time")
    private Long consumeTime;

    @CreatedDate
    @Column(name = "create_time")
    private LocalDateTime createTime;

    @LastModifiedDate
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    @Column(name = "status", length = 32)
    private String status;

    @Column(name = "remark", length = 64)
    private String remark;
}